package com.spa.infrastructure.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.spa.application.command.admin.AdminCarouselAddCommand;
import com.spa.application.command.admin.AdminCarouselEditCommand;
import com.spa.application.dto.PageResult;
import com.spa.application.dto.admin.AdminCarouselDTO;
import com.spa.application.dto.member.MemberIndexCarouselDTO;
import com.spa.application.query.admin.AdminCarouselQuery;
import com.spa.domain.entity.Carousel;
import com.spa.infrastructure.enums.dict.carousel.CarouselTypeEnum;
import com.spa.infrastructure.repository.condition.CarouselCondition;
import com.spa.infrastructure.repository.po.CarouselPO;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper
@MapperConfig(unmappedTargetPolicy = ReportingPolicy.WARN)
public interface CarouselServiceMapperStruct {

    CarouselServiceMapperStruct INSTANCE = Mappers.getMapper(CarouselServiceMapperStruct.class);

    List<Carousel> po2Entity4List(List<CarouselPO> poList);
    Carousel po2Entity(CarouselPO po);

    //
    //=========member==============
    //
    List<MemberIndexCarouselDTO> entity2MemberDto4List(List<Carousel> entity);


    //
    //============admin==============
    //
    CarouselPO commandAdmin2Entity(AdminCarouselAddCommand command);

    CarouselPO commandAdmin2Entity(AdminCarouselEditCommand command);
    CarouselCondition queryAdmin2Carousel(AdminCarouselQuery query);

    Page<Carousel> po2Entity4Page(Page<CarouselPO> po);
    @Mapping(source = "type", target = "type", qualifiedByName = "int2Enum")
    AdminCarouselDTO entity2Dto(Carousel entity);
    PageResult<AdminCarouselDTO> entity2Dto4Page(Page<Carousel> entity);



    @Named("int2Enum")
    default CarouselTypeEnum int2Enum(int status) {
        return CarouselTypeEnum.byCode(status);
    }



}
